/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.event.thuoc;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import model.dao.thuoc.ThuocDAO;
import org.hibernate.HibernateException;

/**
 *
 * @author nv_ca@live.com
 */
public class ThuocXoaFull_evt {

    public static final void btnCloseActionPerformed(JDialog dlg) {
        dlg.dispose();
    }

    public static final void btnDelActionPerformed(JTextField textField) {
        int thuocMa;
        try {
            thuocMa = Integer.parseInt(textField.getText());
            ThuocDAO.delete(thuocMa);
        } catch (NumberFormatException | HibernateException ex) {
            JOptionPane.showMessageDialog(null, "Mã thuốc sai.");
            return;
        }
        JOptionPane.showMessageDialog(null, "Đã xóa thuốc có mã số " + thuocMa + ".");
    }

}
